1. Field of the Invention
The present invention relates to communication devices, and more particularly, to a communication device for routing packets.
2. Description of the Related Art
A Layer 2 switch forwards packets at the Data-link layer (Layer 2) of the OSI reference model. Ethernet® is a typical connection scheme for LANs (Local Area Networks) and concerned with the Layer 2 of the OSI reference model.
FIG. 13 illustrates routing control of a Layer 2 switch. In the figure, reference numerals 131a, 131b, . . . , 131n denote packets input from n input ports, not shown. The input packets 131a, 131b, . . . , 131n are routed in accordance with their header information and written in corresponding queues 132a, 132b, . . . , 132n associated with n output ports, not shown. The packets 131a, 131b, . . . , 131n stored in the queues 132a, 132b, . . . , 132n are output thereafter from the corresponding output ports. The packets are routed on a packet-by-packet basis (Ethernet frame header+data).
The packets 131a, 131b, . . . , 131n in the queues 132a, 132b, . . . 132n are read out and stored in read buffers 133a, 133b, . . . , 133n. The packets 131a, 131b, . . . , 131n stored in the read buffers 133a, 133b, . . . , 133n are then read out by a read controller 134 and sent to the output ports, not shown. In FIG. 13, reference numerals 135a, 135b, . . . , 135n represent packets being output to the output ports.
A Layer 2 switch not only forwards one input packet to a single route but copies an input packet to be output to multiple routes, as in broadcasting or multicasting. In the case of broadcasting or multicasting a packet, the packet is copied and the copies are stored in the corresponding queues 132a, 132b, . . . , 132n. In the illustrated example, the packets 131n, namely, packets P5 and P6 are broadcast or multicast. In this case, the packets P5 and P6 (131n) are copied to all queues 132a, 132b, . . . , 132n and are output from all output ports, as indicated by the packets 135a, 135b, . . . , 135n. 
FIG. 14 illustrates packet copying control. As shown in the figure, a packet 141 input from an input port is copied to make n copies, which are written in the respective queues 132a, 132b, . . . , 132n. The packets 141 stored in the queues 132a, 132b, . . . , 132n are then output from the respective output ports. In FIG. 14, the read buffers 133a, 133b, . . . , 133n and the read controller 134 appearing in FIG. 13 are omitted.
Meanwhile, packets have variable lengths, and therefore, when reading packets from the queues 132a, 132b, . . . , 132n, the lengths of packets to be read out must be taken into account. Also, the time required to copy a packet to the queues 132a, 132b, . . . , 132n is proportional to (packet length)×(number of copies), and thus varies depending on the packet length.
FIG. 15 illustrates difference in copying control according to packet lengths. Suppose the case where m shortest packets 151 or a single longest packet 152 is input, as illustrated. The total data amount of the m packets 151 is equal to the data amount of the single longest packet 152.
When copying the packet 152, the packet has only to be copied n times (n: number of output ports). On the other hand, in the case of copying the packets 151, copying operation must be performed n×m times. Thus, the short packets require more copying operations than the long packet, even though the data amounts are the same, lowering transfer efficiency. Also, where packets have different lengths such as the packets 151 and 152, the circuit for reading the packets from the queues 132a, 132b, . . . , 132n is required to read the packets taking account of their packet lengths.
As conventional techniques, a network adapter has been proposed in which copying between memories of a host computer is abolished to thereby improve the memory use efficiency (see, e.g., Japanese Patent Application No. 2005-84002).
Since packets have variable lengths, the packet lengths need to be taken into account when reading packets from queues, giving rise to the problem that the configuration of the circuit for reading out packets becomes complicated.
Also, when packets are copied to queues for the purpose of broadcasting or multicasting, a long copying time is required if the packets to be copied are short in length.